import table from '@/components/dt/table/render.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
    // {
    //   title: '公司',
    //   field: 'orgName',
    //   minWidth: 300
    // },
    {
      title: '服务信息标题',
      field: 'serviceTitle',
      minWidth: 180
    },
    {
      title: '是否展示',
      field: 'displayStatus',
      minWidth: 120,
      slots:{
        default: (params, h)=>{
          return table.cell.text(h, {
            value: params.row.displayStatus==1 ? '展示' : '隐藏'
          })
        }
      }
    },
    {
      title: '最近更新时间',
      field: 'updateTime',
      minWidth: 120
    },
    {
      title: '操作人',
      field: 'updateName',
      minWidth: 120,
      slots:{
        default: (params, h)=>{
          return table.cell.text(h, {
            value: params.row.updateName?params.row.updateWorkNo?params.row.updateName + '('+params.row.updateWorkNo+')':params.row.updateName:'-'
          })
        }
      }
    },
    {
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'checkFun',
            data: params.row
          })
          if(_this.isEdit){
            btns.push({
              title: '编辑',
              event: 'editFun',
              data: params.row
            })
            btns.push({
              title: '删除',
              event: 'delFun',
              data: params.row
            })
          }
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
  }

}

export default Column